$(function(){
	//init();
	cssLoad();
});

//初始化加载
function init(){
	//使用json数据存储一个对象
	var arrStatus = new Array("","自由行","纯玩团");	
	//使用json存储多个对象
	var jsonUlArrs = [
						
						{"trName":"成都市内亲子游","trType":"1","trPrice":"200","trPhone":"13574556682","trUser":"章若阳","createTime":"2021-08-07"},
						{"trName":"峨眉山+九寨沟轻松游","trType":"2","trPrice":"500","trPhone":"16833556681","trUser":"孙媚","createTime":"2021-08-05"},
						{"trName":"都江堰+青城山一日游","trType":"1","trPrice":"100","trPhone":"18774556690","trUser":"王释晖","createTime":"2021-08-04"}	,
					];
	var $ulStr = "";
	
	//清空.last层
	$(".last").empty();
	$(jsonUlArrs).each(function(index){
		var arrJson = jsonUlArrs[index];
		$ulStr += `<ul>
							<li>${arrJson.trName}</li>
							<li class="type">${arrStatus[arrJson.trType]}</li>
							<li>${arrJson.trPrice}</li>
							<li>${arrJson.trPhone}</li>
							<li>${arrJson.trUser}</li>
							<li>${arrJson.createTime}</li>
							<li>
								<a href="javascript:void(0);">详情</a>&nbsp;&nbsp;
								<a href="javascript:void(0);" class="del">删除</a>
								</li>
						</ul>`;
	});
	$(".last").append($ulStr);
	cssLoad();
}

//样式方法
function cssLoad(){
	//使用jQuery进行隔行换色
	$(".last ul").odd().css("background-color","#ccc");
	
	// //状态字体变色
	// $(".type").each(function(){
	// 	if($(this).text() == "自由行"){
	// 		$(this).css("color","royalblue");
	// 	}
	// 	if($(this).text() == "纯玩团"){
	// 		$(this).css("color","yellow");
	// 	}
	// });
	
	// //使用jQuery动态删除当前数据
	// $(".del").click(function(){
	// 	if(confirm("确认删除？")){
	// 		$(this).parent().parent().remove();
	// 		loadBg();
	// 	}
	// });

	//鼠标移进
	$(".last ul").mouseover(function(){
		$(this).addClass("bg");
	});
	//鼠标移出
	$(".last ul").mouseout(function(){
		$(this).removeClass("bg");
	});
}

//隔行换色
function loadBg() {
	var aLi = document.getElementsByTagName('ul');
		for (var i = 0; i < aLi.length; i++) {
			if (i % 2 == 0) {
				aLi[i].style.background = '#ccc';
				} else {
					aLi[i].style.background = '';
					}
		}
}